﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Auditiac.FluentMapping
{
    public class AccountMap: EntityTypeConfiguration<Account>
    {
        public AccountMap()
        {
            // Primary key
            this.HasKey(t => t.Id);
                

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Username)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Password)
                .IsRequired()
                .HasMaxLength(100);          

            this.Property(t => t.Email)
                .HasMaxLength(100);          

            this.Property(t => t.Address)
                .IsOptional()
                .HasMaxLength(100);

            this.Property(t => t.FirstName)
                .HasMaxLength(30);

            this.Property(t => t.MiddleName)
                .IsOptional()
                .HasMaxLength(20);

            this.Property(t => t.LastName)
                .HasMaxLength(30);

            this.Property(t => t.CellPhone)
                .IsOptional()
                .HasMaxLength(20);

            
        }
    }
}
